import React from 'react';
import PropTypes from 'prop-types';
import {Card, Divider} from 'antd';
import {fileType} from '../Enum';
import {formatMessage} from './intl';
import FileUpload from './FileUpload';
import ImageUpload from './ImageUpload';
import DescriptionList from 'ant-design-pro/lib/DescriptionList';
export class AthTypeList extends React.PureComponent {
    state = {
        showSelectPartPanel: false
    }
    onChangeUploadPhoto = data => {
        this.props.onChangeUploadPhoto(data);
    };
    onRemovePhoto = data => {
        this.props.onRemovePhoto(data);
    };
    onChangeUploadFile = data => {
        this.props.onChangeUploadFile(data);
    };
    onRemoveFile = data => {
        this.props.onRemoveFile(data);
    };
    render() {
        const attachmentsPhoto = this.props.athDetails
            ? this.props.athDetails.find(item => item.fileType === fileType.图片) ||
            [] : [];
        const attachmentsFile = this.props.athDetails
            ? this.props.athDetails.find(item => item.fileType === fileType.文件) ||
            [] : [];
        return (
            <Card title={formatMessage({
                id: 'athTypeList.operation.photo',
                defaultMessage: '图片资料'
            })}>
                <DescriptionList>
                    <ImageUpload
                        onChange={this.onChangeUploadPhoto}
                        onRemove={this.onRemovePhoto}
                        fileList={attachmentsPhoto.attachments || []} />
                </DescriptionList>
                <Divider />
                <DescriptionList>
                    <FileUpload
                        onChange={this.onChangeUploadFile}
                        onRemove={this.onRemoveFile}
                        fileList={attachmentsFile.attachments || []} />
                </DescriptionList>
            </Card>
        );
    }
}

AthTypeList.propTypes = {
    athDetails: PropTypes.array,
    onChangeUploadFile: PropTypes.func,
    onChangeUploadPhoto: PropTypes.func,
    onRemoveFile: PropTypes.func,
    onRemovePhoto: PropTypes.func,
};
export default AthTypeList;
